<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">

        function scream(animal){
            switch(animal){
                case 'dog':
                    console.log('wang');
                    return;
                case 'cat': 
                    console.log('miao');
                    break;
                case 'fish': 
                    console.log('o~o~o');
                    break;
            }
        }




        /*输入数字，逆转输出汉字*/

        var str = '123456';
        document.write(str.charAt(0)); // 返回位置0的字符

        function reverse(){
            var num = window.prompt('请输入一串数字：');
            var str = "";
            for(var i = num.length - 1; i >= 0; i --){
                str += transform(num[i]);
            }
            console.log(str);
            return str;
        }


        function transform(target){
            switch(target) {
                case '0': 
                    return "零";
                case '1': 
                    return "一";
                case '2': 
                    return "二";
                case '3': 
                    return "三";
                case '4': 
                    return "四";
                case '5': 
                    return "五";
                case '6': 
                    return "六";
                case '7': 
                    return "七";
                case '8': 
                    return "八";
                case '9': 
                    return "九";
            }
        }
        // 递归法求阶乘
        // 递归法书写直观，逻辑简单，代码少，计算复杂度较高
        // 找规律，找出口。规律一般来源于递推公式
        function jc(n){
            if(n == 0 || n == 1){
                return 1;
            }else{
                return n * jc(n - 1);
            }
        }
        function jc1(n){
            var res = 1;
            if(n > 1){
                for(var i = n; i > 0; i --){
                    res *= i;
                }
            }
            return res;
        }

        function Fibonacci(n) {
            if (n == 1 || n == 2){
                return 1;
            }
            return Fibonacci(n - 1) + Fibonacci(n - 2);
        }
    </script>
</body>
</html>